String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
/*Date.prototype.format = function(format){
   var o = {
     "M+" : this.getMonth()+1, //month
     "d+" : this.getDate(),    //day
     "h+" : this.getHours(),   //hour
     "m+" : this.getMinutes(), //minute
     "s+" : this.getSeconds(), //second
     "q+" : Math.floor((this.getMonth()+3)/3), //quarter
     "S" : this.getMilliseconds() //millisecond
   };
   if (/(y+)/.test(format))
		format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4
						- RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(format))
			format = format.replace(RegExp.$1, RegExp.$1.length == 1
							? o[k]
							: ("00" + o[k]).substr(("" + o[k]).length));
	return format;
};*/

function namespace(ns) {
	if (typeof(ns) != "string")
		return;
	ns = ns.split(".");
	var o, ni;
	for (var i = 0, len = ns.length; i < len, ni = ns[i]; i++) {
		try {
			o = (o ? (o[ni] = o[ni] || {}) : (eval(ni + "=" + ni + "||{}")))
		} catch (e) {
			o = eval(ni + "={}")
		}
	}
}

function copyProperties(to, from) {
	if (!to || !from) {
		return;
	}
	if ($.isArray(to) && $.isArray(from)) {
		$.each(from, function(i, n) {
					var flag = false;
					$.each(to, function(j, m) {
								if (n.name == m.name) {
									m.value = n.value;
									flag = true;
									return;
								}
							});
					if (!flag) {
						to.push(n);
					}
					return;
				});
		return to;
	}
};

/**
 * 判断对象/变量内容是否不为空
 * @param {} obj
 * @return {}
 */
function isNotEmpty(obj){	
	if(typeof obj != 'undefined' && obj != null && obj.length != 0){
		if(typeof obj == 'string'){
			return (obj.toUpperCase()!='NULL' && obj.trim()!='') ? true : false;
		}else{
			return true;
		}
	}else{
		return false;
	}
}

/**
 * 判断对象/变量内容是否为空
 * @param {} obj
 * @return {}
 */
function isEmpty(obj){
	return !isNotEmpty(obj);
}

